<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>启动图管理</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"><!-- 确保适当的绘制和触屏缩放 -->
    <link rel="stylesheet" href="{$url_css}bootstrap.min.css" type="text/css">
    <link rel="stylesheet" href="{$url_css}admin.css" type="text/css">
    <script type="text/javascript" src="{$url_js}jquery-1.12.0.min.js"></script>
    <script type="text/javascript" src="{$url_js}calendar/WdatePicker.js"></script>
</head>
<body>

<div class="container" style="width:96%">
    <form action="?do=Add" method="post" enctype="multipart/form-data">
        <table class="table table-bordered table-striped" align="center">
            <tbody>
                <tr><td colspan="3"><h5>添加启动图</h5></td></tr>
                <tr>
                    <td class="col-xs-2">应用名：</td>
                    <td>
                        <select id="app_id" name="app_id" class="form-control" style="width: 300px;">
                            <option value="0">请选择需要更新的应用</option>
                            {foreach from=$app_ids key=key item=item}
                                <option value="{$key}">{$item.AppName|html}</option>
                            {/foreach}
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>启动图名称：</td>
                    <td><input type="text" class="form-control" id="name" name="name" value="" placeholder="启动图名称" style="width: 300px;" /></td>
                </tr>
                <tr>
                    <td>启动图点击URL：</td>
                    <td><input type="text" class="form-control" id="url" name="url" value="" placeholder="启动图点击URL" style="width: 300px;" /></td>
                </tr>
                <tr>
                    <td>启动图描述：</td>
                    <td><textarea rows="5" cols="20" class="form-control" id="description" name="description" style="width: 500px;" placeholder="启动图描述"></textarea></td>
                </tr>
                <tr>
                    <td>启动图显示开始时间：</td>
                    <td><input class="form-control" id="start_time" name="start_time" type="text" onFocus="WdatePicker({literal}{startDate:'%y-%M-%d 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',maxDate:'#F{$dp.$D(\'end_time\')}'}{/literal});" value="" readonly="" style="width: 200px;" /></td>
                </tr>
                <tr>
                    <td>启动图显示结束时间：</td>
                    <td><input class="form-control" id="end_time" name="end_time" type="text" onFocus="WdatePicker({literal}{startDate:'%y-%M-%d 23:59:59',dateFmt:'yyyy-MM-dd HH:mm:ss',minDate:'#F{$dp.$D(\'start_time\')}'}{/literal});" value="" readonly="" style="width: 200px;" /></td>
                </tr>
                <tr>
                    <td>上传图片<br>
                        (仅限jpg&png格式,<br>
                        大小为： 750 X 1024)</td>
                    <td><input type="file" class="image_table" id="appscreen" name="appscreen" style="width: 200px;" /> </td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td >
                        <input type="submit" id="add_btn" class="btn btn-primary" value="添加" />
                        <input type="button" onclick="history.back()" class="btn btn-primary" value="取消" />
                    </td>
                </tr>
            </tbody>
        </table>
    </form>
</div>
<div>&nbsp;</div>

{literal}
<script type="text/javascript">

    $("#add_btn").click(function (){
        var app_id = parseInt($("#app_id").val()),
            name = $.trim($("#name").val()),
            description = $.trim($("#description").val()),
            start_time = $.trim($("#start_time").val()),
            end_time = $.trim($("#end_time").val()),
            appscreen = $.trim($('#appscreen').val());

        if (!app_id){
            top.swal('出错了', '请选择应用！', 'error');
            return false;
        }
        if (!name.length){
            top.swal('出错了', '启动图名称不能为空！', 'error');
            return false;
        }
        if (!description.length){
            top.swal('出错了', '启动图描述不能为空！', 'error');
            return false;
        }
        if (!start_time.length){
            top.swal('出错了', '启动图显示开始时间不能为空！', 'error');
            return false;
        }
        if (!end_time.length){
            top.swal('出错了', '启动图显示结束时间不能为空！', 'error');
            return false;
        }

        if (!/\.(jpg|png)$/.test(appscreen)) {
            top.swal('出错了', '未选择图片, 且图片必须为jpg格式', 'error');
            return false;
        }

        return true;
    });
</script>
{/literal}

</body>
<html>